/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 *
 * @author Aganguly
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //  List<String> dataReceived = getAllModels();
//        if (dataReceived == null) {
//            System.out.println("data not received");
//        } else if (dataReceived.size() == 0) {
//            System.out.println("Data Recieved but null");
//        } else {
//            for (String s : dataReceived) {
//                System.out.println("Data Received: " + s);
//            }
//        }
        //  boolean b = addItem("BLX Mountain Bike", 11);
        //if(b)
        //  System.out.println("Current Stocks Available: " + getAvailableStocks("BLX Mountain Bike"));
        //else
        //   System.out.println("item not found");

        long isCreated = createNewShipment("Shipment-ABC", new GregorianCalendar());
        if (isCreated > 0) {
            System.out.println("added shipment id: " + isCreated);
            System.out.println("current status of shipment: " + getShipmentStatus(isCreated));
            System.out.println("Updating the status to delivered");
            setShipmentStatusDelivered(isCreated, "");
            System.out.println("updated status: " + getShipmentStatus(isCreated));
        }
    }

    private static java.util.List<java.lang.String> getAllModels() {
        scraper.bikes.DatafinderService service = new scraper.bikes.DatafinderService();
        scraper.bikes.Datafinder port = service.getDatafinderPort();
        return port.getAllModels();
    }

    private static int getAvailableStocks(java.lang.String itemName) {
        wh.ironcity.services.InventoryService service = new wh.ironcity.services.InventoryService();
        wh.ironcity.services.Inventory port = service.getInventoryPort();
        return port.getAvailableStocks(itemName);
    }

    private static Boolean addItem(java.lang.String itemName, int stockQuantity) {
        wh.ironcity.services.InventoryService service = new wh.ironcity.services.InventoryService();
        wh.ironcity.services.Inventory port = service.getInventoryPort();
        return port.addItem(itemName, stockQuantity);
    }

    private static long createNewShipment(java.lang.String shipmentDetails, GregorianCalendar shippingDate) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        XMLGregorianCalendar xmlCalShiping = new XMLGregorianCalendarImpl(shippingDate);
        return port.createNewShipment(shipmentDetails, xmlCalShiping);
    }

    private static String getShipmentStatus(long shipmentId) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        return port.getShipmentStatus(shipmentId);
    }

    private static String getShipperDetails(long shipmentId) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        return port.getShipperDetails(shipmentId);
    }

    private static Boolean setShipmentStatusDelivered(long shipmentId, java.lang.String status) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        return port.setShipmentStatusDelivered(shipmentId, status);
    }

    private static Boolean setShipmentStatusNotDelivered(int shipmentId, java.lang.String status) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        return port.setShipmentStatusNotDelivered(shipmentId, status);
    }

    private static Boolean setShipmentStatusShipped(int shipmentId, java.lang.String status) {
        bikes.ship.ShipperService service = new bikes.ship.ShipperService();
        bikes.ship.Shipper port = service.getShipperPort();
        return port.setShipmentStatusShipped(shipmentId, status);
    }
}
